import csv
import random

from GeneticAlgorithm import Individual
# from ExperimentSimulation import EventLine
from BasicDefinition import Network


# from ExperimentSimulation import GA_Decision

def Random_Decision(network: Network, cx, cy, block_idx, Seq_Length):
    scheme_seq = []
    # Satellite_list = network.GetAdjSatellites(cx, cy)
    First = network.CoordinationMapping(cx, cy)
    scheme_seq.append(First)
    while len(scheme_seq) < Seq_Length:
        now = scheme_seq[-1]
        now_row, now_col = network.Inv_CoordinationMapping(now)
        Surrounding_Satellites = network.GetAdjSatellites(now_row, now_col)
        scheme_seq.append(random.choice(Surrounding_Satellites))
    return Individual(scheme_seq, 0, 0, 0, cx, cy, network, block_idx)

# for i in range(1, 20):
#     network = Network(8, 8,
#                       1, 3,
#                       8, i,
#                       200, 40,
#                       4, 1000,
#                       1000, 2)
#
#     x = EventLine(network, Random_Decision, 3)
#
#     x.Simulate()

# writer = csv.writer(csv_file)
# writer.writerow([x.TotalDrop / x.TotalMission])
# print("Finished:", i)
# print(x.TotalDrop, x.TotalMission)
